function saveStorage() {
    var data = new Object;
    data.myname = document.getElementById("myname").value;
    data.mypassword = document.getElementById("mypassword").value;
    data.myemail = document.getElementById("myemail").value;
    data.tel = document.getElementById("tel").value;
    data.myage = document.getElementById("myage").value;
    data.mydepartment = document.getElementById("mydepartment").value;
    data.birthdate = document.getElementById("birthdate").value;
    data.myweek = document.getElementById("myweek").value;
    data.mycolor = document.getElementById("mycolor").value;
    data.rank = document.getElementById("rank").value;
    data.texta = document.getElementById("texta").value;
    data.myfile = document.getElementById("myfile").value;
    var str = JSON.stringify(data);
    localStorage.setItem(data.myname,str);
    alert("数据已经保存");
}
function findStorage(id) {
    var find = document.getElementById('find').value;
    var str =localStorage.getItem(find);
    var data = JSON.parse(str)
    var result = "<table border='1' bordercolor='green' cellpadding='1' cellspacing='0'>";
        result +="<tr><td>" +"用户名："+"</td><td>"+data.myname+"</td></tr>" +"<br>";
        result += "<tr><td>密码：</td>"+"<td>"+data.mypassword+"</td></tr>" +"<br>";
        result += "<tr><td>Email：</td>"+"<td>"+data.myemail+"</td></tr>"+"<br>";
        result += "<tr><td>Phone：</td>"+"<td>"+data.tel+"</td></tr>" +"<br>";
        result += "<tr><td>年龄：</td>"+"<td>"+data.myage+"</td></tr>" +"<br>";
        result += "<tr><td>专业：</td>"+"<td>"+data.mydepartment+"</td></tr>" +"<br>";
        result += "<tr><td>出生日期：</td>"+"<td>"+data.birthdate+"</td></tr>" +"<br>";
        result += "<tr><td>周数：</td>"+"<td>"+data.myweek+"</td></tr>" +"<br>";
        result += "<tr><td>您选择的颜色：</td>"+"<td>"+data.mycolor+"</td></tr>" +"<br>";
        result += "<tr><td>英语等级：</td>"+"<td>"+data.rank+"</td></tr>" +"<br>";
        result += "<tr><td>备注：</td>"+"<td>"+data.texta+"</td></tr>" +"<br>";
        result += "<tr><td>文件：</td>"+"<td>"+data.myfile+"</td></tr>" +"<br>";
        result += "</table>";
        var target = document.getElementById(id);
        target.innerHTML = result;
}

function loadAll(){
    var list = document.getElementById("list");
    if(localStorage.length>0){
        var result = "<table border='1' bordercolor='yellow' cellpadding='1' cellspacing='0'>";
        result += "<tr><td>用户名</td><td>密码</td><td>Email</td><td>Phone</td><td>年龄</td><td>专业</td><td>出生日期</td><td>周数</td><td>您选择的颜色</td><td>英语等级</td><td>备注</td><td>文件</td></tr>";
        for(var i=0;i<localStorage.length;i++){
            var name = localStorage.key(i);
            var str = localStorage.getItem(name);
            var contact = JSON.parse(str);
            result += "<tr><td>"+contact.myname+"</td><td>"+contact.mypassword+"</td><td>"+contact.myemail+"</td><td>"+contact.tel+"</td>" +
                "<td>"+contact.myage+"</td><td>"+contact.mydepartment+"</td><td>"+contact.birthdate+"</td><td>"+contact.myweek+"</td><td>"+contact.mycolor+"</td><td>"+
                contact.rank+"</td><td>"+contact.texta+"</td><td>"+contact.myfile+"</td><td>"+"</tr>";
        }
        result += "</table>";
        list.innerHTML = result;
    }else{
        list.innerHTML = "数据为空";
    }
}